﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;

namespace PickGold.Com
{
	static class common
	{
	}

	/// <summary/>
	public class ComUtil
	{
		/// <summary/>
		public static void CreateShortcut(string shortcut, string target, string arguments = null, string startup = null, string description = null)
		{
			Shortcut.Create(shortcut, target, arguments, startup, description);
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class CPoint
	{
		/// <summary/>
		public CPoint()
		{
			this.X = 0;
			this.Y = 0;
		}

		/// <summary/>
		public CPoint(int x, int y)
		{
			this.X = x;
			this.Y = y;
		}

		/// <summary/>
		public int X;
		/// <summary/>
		public int Y;

		/// <summary/>
		public override string ToString()
		{
			return base.ToString() + string.Format(" X: {0} Y: {1}", this.X, this.Y);
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class CSize
	{
		/// <summary/>
		public CSize()
		{
			this.Width = 0;
			this.Height = 0;
		}

		/// <summary/>
		public CSize(int width, int height)
		{
			this.Width = width;
			this.Height = height;
		}

		/// <summary/>
		public int Width;
		/// <summary/>
		public int Height;

		/// <summary/>
		public override string ToString()
		{
			return base.ToString() + string.Format(" Width: {0} Height: {1}", this.Width, this.Height);
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class CRectangle
	{
		/// <summary/>
		public int Left;
		/// <summary/>
		public int Top;
		/// <summary/>
		public int Right;
		/// <summary/>
		public int Bottom;

		/// <summary/>
		public CRectangle()
		{
			this.Left = 0;
			this.Top = 0;
			this.Right = 0;
			this.Bottom = 0;
		}

		/// <summary/>
		public CRectangle(int x, int y, int width, int height)
		{
			this.Left = x;
			this.Top = y;
			this.Right = x + width;
			this.Bottom = y + height;
		}

		/// <summary/>
		public CRectangle(CPoint point, CSize size)
		{
			this.Left = point.X;
			this.Top = point.Y;
			this.Right = point.X + size.Width;
			this.Bottom = point.Y + size.Height;
		}

		/// <summary/>
		public CPoint Center
		{
			get
			{
				return new CPoint(this.X + this.Width / 2, this.Y + this.Height / 2);
			}
		}

		/// <summary/>
		public CPoint Point
		{
			get
			{
				return new CPoint(this.Left, this.Top);
			}
		}

		/// <summary/>
		public CSize Size
		{
			get
			{
				return new CSize(this.Width, this.Height);
			}
		}

		/// <summary/>
		public int X
		{
			set
			{
				this.Left = value;
			}
			get
			{
				return this.Left;
			}
		}

		/// <summary/>
		public int Y
		{
			set
			{
				this.Top = value;
			}
			get
			{
				return this.Top;
			}
		}

		/// <summary/>
		public int Width
		{
			get
			{
				return this.Right - this.Left;
			}
		}

		/// <summary/>
		public int Height
		{
			get
			{
				return this.Bottom - this.Top;
			}
		}

		#region Automation

		/// <summary/>
		public CRectangle createItem(int x, int y, int width, int height)
		{
			return new CRectangle(x, y, width, height);
		}

		/// <summary/>
		public CRectangleList createList()
		{
			return new CRectangleList();
		}

		/// <summary/>
		public int addToList(CRectangleList rectangleList, CRectangle rectangle)
		{
			rectangleList.Add(rectangle);
			return rectangleList.Count;
		}

		/// <summary/>
		public int addToList(CRectangleList rectangleList, int x, int y, int width, int height)
		{
			rectangleList.Add(x, y, width, height);
			return rectangleList.Count;
		}

		/// <summary/>
		public int getListCount(CRectangleList rectangleList)
		{
			return rectangleList.Count;
		}

		/// <summary/>
		public CRectangle getListItem(CRectangleList rectangleList, int index)
		{
			return rectangleList[index];
		}

		#endregion

		/// <summary/>
		public override string ToString()
		{
			return base.ToString() + string.Format(" Left:{0} Top:{1} Right: {2} Bottom: {3} Width: {4} Height: {5}", this.Left, this.Top, this.Right, this.Bottom, this.Width, this.Height);
		}
	}

	/// <summary/>
	[Serializable]
	[ComVisible(true)]
	[AutomationProxy(true)]
	[ClassInterface(ClassInterfaceType.AutoDispatch)]
	public class CRectangleList : List<CRectangle>
	{
		/// <summary/>
		public CRectangleList() : base() { }
		/// <summary/>
		public CRectangleList(int capacity) : base(capacity) { }

		/// <summary/>
		public void Add(int x, int y, int width, int height)
		{
			base.Add(new CRectangle(x, y, width, height));
		}
		/// <summary/>
		public void Add(CPoint point, CSize size)
		{
			base.Add(new CRectangle(point, size));
		}
	}

	/// <summary/>
	[ComVisible(true), ComImport()]
	[Guid("6d5140c1-7436-11ce-8034-00aa006009fa")]
	[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
	public interface IServiceProvider
	{
		/// <summary/>
		[PreserveSig]
		[return: MarshalAs(UnmanagedType.I4)]
		uint QueryService(ref System.Guid guidService, ref System.Guid riid, [MarshalAs(UnmanagedType.Interface)]out object ppvObject);
	}

	/// <summary/>
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")]
	public interface IObjectWithSite
	{
		/// <summary/>
		void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] Object pUnkSite);
		/// <summary/>
		void GetSite(ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out Object ppvSite);
	}

	/// <summary/>
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("00000114-0000-0000-C000-000000000046")]
	public interface IOleWindow
	{
		/// <summary/>
		void GetWindow(out System.IntPtr phwnd);
		/// <summary/>
		void ContextSensitiveHelp([In] bool fEnterMode);
	}

	/// <summary/>
	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("012dd920-7b26-11d0-8ca9-00a0c92dbfe8")]
	public interface IDockingWindow
	{
		/// <summary/>
		void GetWindow(out System.IntPtr phwnd);
		/// <summary/>
		void ContextSensitiveHelp([In] bool fEnterMode);
		/// <summary/>
		void ShowDW([In] bool fShow);
		/// <summary/>
		void CloseDW([In] UInt32 dwReserved);
		/// <summary/>
		void ResizeBorderDW(IntPtr prcBorder, [In, MarshalAs(UnmanagedType.IUnknown)] Object punkToolbarSite, bool fReserved);
	}

}
